import psutil
import socket

def get_ipv6_addresses():
    ipv6_addresses = []
    # 获取所有网络接口的信息
    for interface, addrs in psutil.net_if_addrs().items():
        for addr in addrs:
            # 检查地址族是否为IPv6
            if addr.family == socket.AF_INET6:
                # 过滤掉本地回环地址和链路本地地址
                if not addr.address.startswith('::') and not addr.address.startswith('fe80:'):
                    ipv6_addresses.append(addr.address)
    return ipv6_addresses

# 使用函数并打印结果
ipv6_list = get_ipv6_addresses()
print(ipv6_list)
